<template>
  <div class="personalContainer">
    <div
      class="personal-header"
      :style="{ display: isShow ? 'block' : 'none' }"
    >
      <div class="header-title">影风</div>
      <span class="iconfont icon-xiaoxitongzhi header-icon"></span>
    </div>
    <div class="bgimg">
      <span class="iconfont icon-xiaoxitongzhi message"></span>
      <img class="picture" @click="toEditPersonal" :src="url" alt="bg.jpeg" />
      <span class="userName">影风</span>
    </div>
    <div class="middle">
      <div class="middle-header">
        <span style="font-size: large">我的小记</span>
        <span style="line-height: 30px; color: #999">全部 ></span>
      </div>
      <slider-card />
      <my-collect-card></my-collect-card>
    </div>
    <my-personal-list />
    <div class="bottom-hr" style="height: 10px"></div>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from "vue-router";
import { Toast } from "vant";
import sliderCard from "../components/personal/slider.vue";
import myCollectCard from "../components/personal/myCollectCard.vue";
import myPersonalList from "../components/personal/myPersonalList.vue";
import MyPersonalList from "../components/personal/myPersonalList.vue";
import { onBeforeMount } from "@vue/runtime-core";
import request from "../api";
import { onBeforeUnmount, onMounted, ref } from "@vue/runtime-core";
type firstWeacher<T = undefined> = {
    result: {
      realtime: Object;
    },
    reason:string
};
let isShow = ref<boolean>(false);
const router = useRouter();
let url = ref<string>(
  "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fblog%2F202108%2F22%2F20210822093116_21ae3.thumb.1000_0.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1650445647&t=6051584e9f898c3facb8143fdf3d0e76"
);
const toEditPersonal = () => {
  router.push({ name: "edit", query: { url: url.value } });
};
onMounted(() => {
  window.addEventListener(
    "scroll",
    function () {
      var scrollTop =
        document.documentElement.scrollTop || document.body.scrollTop;
      // console.log(scrollTop);
      if (scrollTop >= 40) {
        isShow.value = true;
      } else {
        isShow.value = false;
      }
    },
    true
  );
});
onBeforeUnmount(() => {
  window.removeEventListener(
    "scroll",
    function () {
      console.log("滚动事件已注销");
    },
    true
  );
});

onBeforeMount(() => {
});
</script>

<style lang="less">
@background_url: "../static/imgs/bg.jpeg";
.personalContainer {
  background-color: #f5f5f5;
  .personal-header {
    width: 100%;
    height: 40px;
    line-height: 40px;
    font-size: 16px;
    background: #fff;
    color: #000;
    position: fixed;
    top: 0;
    z-index: 100;
    text-align: center;
    .header-icon {
      position: absolute;
      top: 0;
      right: 10px;
      font-size: 20px;
      color: #666;
    }
  }
  .bgimg {
    position: relative;
    width: 100%;
    height: 200px;
    background-image: url(@background_url);
    background-size: 100% 100%;
    .message {
      position: absolute;
      right: 10px;
      top: 10px;
      font-size: 20px;
      color: #fff;
    }
    .picture {
      position: absolute;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      bottom: 40px;
      left: 20px;
    }
    .userName {
      position: absolute;
      bottom: 65px;
      left: 100px;
      color: #fff;
    }
  }
  .middle {
    background: #fff;
    padding: 15px;
    .middle-header {
      display: flex;
      justify-content: space-between;
    }
  }
}
</style>